package com.cmf.myproject.controller.boss.sysShortCut;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.system.boss.shortcut.SysShortCutService;
import com.system.boss.shortcut.mapper.SysShortCut;
import com.system.core.controller.ControllerBase;
import com.system.core.results.ResultBase;
import com.system.core.view.layui.table.TableViewReqDto;
import com.system.core.view.layui.table.TableViewRspDto;

@Controller
@RequestMapping("boss/sys_short_cut")
public class SysShortCutController extends ControllerBase {
	@Autowired
	private SysShortCutService sysShortCutService;
	
	@RequiresPermissions("sysShortCut_topage")
	@RequestMapping(value = "to_page",method = RequestMethod.GET)
	public String toPage() {
		getModelMap().put("sysShortCutOwnerTypeEnum", com.cmf.myproject.dal.mybatis.enums.SysShortCutOwnerTypeEnum.getAllEnum());
		getModelMap().put("sysShortCutOpenTypeEnum", com.cmf.myproject.dal.mybatis.enums.SysShortCutOpenTypeEnum.getAllEnum());
		return "/boss/sysShortCut/sysShortCut-list";
	}
	
	@RequestMapping(value = "query_list",method = RequestMethod.POST)
	@ResponseBody
	public TableViewRspDto<SysShortCut> sysShortCutQueryList(SysShortCut filter,TableViewReqDto page) {
		TableViewRspDto<SysShortCut> rsp = sysShortCutService.shortCutList(filter,page);
		return rsp;
	}
	
	@RequestMapping(value = "get_item_by_key",method = RequestMethod.POST)
	@ResponseBody
	public SysShortCut sysShortCutGetByPrimaryKey(SysShortCut sysShortCut){
		return sysShortCutService.getShortCutByKey(sysShortCut.getShortCutId());
	}
	
	@RequiresPermissions("sysShortCut_add_opt")
	@RequestMapping(value = "add_item",method = RequestMethod.POST)
	@ResponseBody
	public ResultBase sysShortCutAddItem(@Validated SysShortCut sysShortCut) {
		return sysShortCutService.shortCutAdd(sysShortCut);
	}
	
	@RequiresPermissions("sysShortCut_edit_opt")
	@RequestMapping(value = "update_item",method = RequestMethod.POST)
	@ResponseBody
	public ResultBase sysShortCutUpdateItem(@Validated SysShortCut sysShortCut) {
		return sysShortCutService.shortCutUpdate(sysShortCut);
	}
	
	@RequiresPermissions("sysShortCut_delete_opt")
	@RequestMapping(value = "delete_item",method = RequestMethod.POST)
	@ResponseBody
	public ResultBase sysShortCutDeleteItem(@RequestBody List<Long> keys) {
		return sysShortCutService.shortCutDeleteByKey(keys);
	}
}
